package com.duoduo.common.util.myhelper;


import com.duoduo.common.api.help.JsonInnerUtil;
import com.duoduo.common.util.myinterface.GenerateKey;

public class StringUtil {

	/**把toString里的类内容地址替换为""
	 * @param str
	 * @return
	 */
	public static String replaceToString(String str) {
		return str.replaceAll("\\@(\\w*)\\[", "@[");
	}

	/**
	 * 将数组转换成字符串
	 *  @param Object[]
	 */
	public static String arrayToString(Object[] objs) throws Exception {
		String ret = "";
		for (Object object : objs) {
			if(object != null){
				String objStr;
				if(object instanceof GenerateKey){
					objStr = ((GenerateKey)object).generateKey();
				}else{
					objStr = JsonInnerUtil.objecttoJSon(object);
				}
				ret += objStr;
			}
		}
		return ret;
	}

}
